//TimerThread
#pragma once

class ChipBus;
class Business;
class CallbackBase;

struct WaitableTimerParameter 
{
	Business* business;
	SYSTEMTIME time;
	CallbackBase* callback;
};


class WaitableTimer
{
public:
	WaitableTimer(CallbackBase* callback);
	~WaitableTimer();

	void Start(SYSTEMTIME const& time);
	void Callback();
private:
	HANDLE m_hTimer;
	CallbackBase* m_callback;
};


class ControlBus
{
public:
	ControlBus(ChipBus& chipBus);
	void Run();

private:
	void UpdateTimer(WaitableTimerParameter const& parameter);

	ChipBus& m_chipBus;
	map<Business*, WaitableTimer*> m_businessWaitableTimerMap;
};